package de.saumya.webfortune.client;

import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;



public class TopicListPanel extends VerticalPanel {
  
  private final QuoteButtons buttons;
  
  private final QuoteController quoteController;
    
  public TopicListPanel(QuoteController quoteController, QuoteButtons buttons) {
    setStyleName("webfortune-TopicListPanel");
    this.quoteController = quoteController;
    this.quoteController.hideQuotes();
    this.buttons = buttons;
    this.buttons.setVisible(false);    
  }

  public void addRadioButton(final Quote quote) {
    RadioButton rb = new RadioButton("topic", quote.topic.displayName);

    rb.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        quote.random();
        quoteController.showQuotes();
        quoteController.load(quote);
        buttons.setQuote(quote);
      }
    });
    add(rb);
  }
}